package de.leuphana.internet.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import de.leuphana.internet.model.Buch;
import de.leuphana.internet.model.Katalog;

public class BuchAnzeigenController extends AbstractController {

	@Override
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		Katalog katalog = null;
		Object object = getServletContext().getAttribute("katalog");
		if(object == null){
			katalog = new Katalog();
		}
		else{
			katalog = (Katalog)object;
		}
		String isbn = httpServletRequest.getParameter("isbn");
		Buch buch = katalog.getBuch(isbn);
		httpServletRequest.setAttribute("buch", buch);
		return new ModelAndView("forward:/Buch");
	}

}